import { ConfigEnv, defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// 引入svg需要用到的插件
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
// https://vitejs.dev/config/
import { viteMockServe } from 'vite-plugin-mock'

export default defineConfig(({ command }: ConfigEnv) => {
  return {
    plugins: [
      vue(),

      createSvgIconsPlugin({
        iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
        symbolId: 'icon-[dir]-[name]',
      }),
      viteMockServe({
        enable:command==='serve' //保证开发阶段可以使用mock接口
      })
    ],

    resolve: {
      alias: {
        '@': path.resolve('./src'),
      },
    },

    //scss全局变量的配置
    css: {
      preprocessorOptions: {
        scss: {
          javascriptEnable: true,
          additionalData: '@import "./src/styles/variable.scss";',
        },
      },
    },

}
})
